package com.example.sunsg.okhttptest.bean;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Created by sunsg on 16/3/9.
 */
public class SpotEditItem implements Parcelable {
    /**描述信息*/
    public static final int TYPE_DESCRIPTION = 0;
    /**plue 加号*/
    public static final int TYPE_PLUE = 1;
    /**图片*/
    public static final int TYPE_IMAGE = 2;
    /**其他信息*/
    public static final int TYPE_OTHER_INFO = 3;

    private int type;
    private SpotEditItemInterface item;

    public SpotEditItem() {
    }

    public SpotEditItem(int type, SpotEditItemInterface item) {
        this.type = type;
        this.item = item;
    }


    public interface  SpotEditItemInterface {

    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public SpotEditItemInterface getItem() {
        return item;
    }

    public void setItem(SpotEditItemInterface item) {
        this.item = item;
    }

    public static Creator<SpotEditItem> getCREATOR() {
        return CREATOR;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(this.type);
        switch (type){
            case TYPE_DESCRIPTION:
                dest.writeParcelable((SpotEditItemDescription)(item), flags);
                break;
            case TYPE_IMAGE:
                dest.writeParcelable((SpotEditItemImage)(item), flags);
                break;
            case TYPE_PLUE:
                dest.writeParcelable((SpotEditItemPlue)item,flags);
                break;
            case TYPE_OTHER_INFO:
                dest.writeParcelable((SpotEditItemOtherInfo)item,flags);
                break;
        }
    }

    protected SpotEditItem(Parcel in) {
        this.type = in.readInt();
        this.item = in.readParcelable(SpotEditItemInterface.class.getClassLoader());
    }

    public static final Parcelable.Creator<SpotEditItem> CREATOR = new Parcelable.Creator<SpotEditItem>() {
        public SpotEditItem createFromParcel(Parcel source) {
            return new SpotEditItem(source);
        }

        public SpotEditItem[] newArray(int size) {
            return new SpotEditItem[size];
        }
    };
}
